fix(staged): strip ANSI escape codes before regex matching in run detection - #629
Conversation
…lines The AI prompt for regex autodetection was matching browser/webview console logs instead of the actual server readiness line. Add guidance to prefer server/framework readiness messages over application-level log output and pick the earliest readiness signal. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Log when regex_matcher and autodetect_poller are started (with execution ID, action name, command/pattern), when each AI poll fires (with line count), and what the AI decides (status, regex, has_endpoint_capture). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…match When the AI-generated regex doesn't match any output line, log sample lines containing "local" with debug escaping so we can see ANSI codes or other hidden characters causing the mismatch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ection Terminal output contains ANSI colour/style codes (e.g. \x1b[1mLocal\x1b[22m) which prevented AI-generated regexes from matching. Use the strip-ansi-escapes crate to clean lines before sending to the AI and before applying regex matches in both spawn_regex_matcher and spawn_autodetect_poller. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…estigation Remove the info-level startup/poll/response logs and sample-line debug logging from spawn_regex_matcher and spawn_autodetect_poller, keeping only the pre-existing warn/error/info logs for actionable states. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 803a160062
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let matched_line = lines.iter().find(|line| re.is_match(line)); | ||
| // Validate that the regex matches at least one line in the current | ||
| // output (using the already-stripped lines). | ||
| let matched_line = clean_lines.iter().find(|line| re.is_match(line)); |
There was a problem hiding this comment.
Match AI regex against full output buffer
The new validation step only checks clean_lines, which is built from tail (last ~200 lines), while previously it searched the full lines buffer. In runs that emit a lot of logs after startup, the readiness line can scroll out of the last 200 lines before this poll executes, so a correct readiness regex gets rejected and autodetect can loop until timeout/NoDetection. This regression is introduced by narrowing validation scope at this line; the check should still consider the full buffered output (after ANSI stripping) to avoid missing earlier readiness lines.
Useful? React with 👍 / 👎.
The AI-generated regex is tested against each output line individually, but the prompt didn't mention this constraint. Add explicit guidance so the AI knows to produce patterns that match within a single line. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
strip-ansi-escapescrate dependencyTest plan
🤖 Generated with Claude Code